package calbs.socket.client;

import calbs.socket.tool.Byte2Hex;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class Bytes2HexDecoder extends ByteToMessageDecoder{

	@Override
	protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
		byte[] req = new byte[in.readableBytes()];
		in.readBytes(req);
		String message = Byte2Hex.Bytes2HexString(req);
		System.out.println("接收到:"+message);
		out.add(message);
	}

}
